package com.controller;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("dCon")
public class DConsumerController {
    @RabbitHandler
    @RabbitListener(queues = "dead")
    public String receive(Message message, Channel channel) throws IOException {
        System.out.println("收到消息" + new String(message.getBody(), "UTF-8"));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        return "d--ok";
    }
}
